home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
pctj8504.arc
/
GRAPH16.BAS
< prev
next >
Wrap
BASIC Source File
|
1986-09-14
|
2KB
|
54 lines
1 '-- GRAPH16.BAS 16-Color Graphics Example
2 '
3 ' This program is very slow, even when compiled.
4 ' It is intended as an example only.
5 ' The EGA must be the currently active display adapter.
20 '
25 ' Runs in Mode E (640 by 200, 16 colors)
30 ' Memory Map: 4 Planes at &HA000
40 ' 8 Pixels per byte, non-interleaved
50 '
60 DEFINT A-Z
70 CLS
75 '-- The following line is for the compiled version only.
80 CALL SETMODE '-- Set Mode after BASIC initialization
100 DEF SEG=&HA000 '-- Video buffer
110 INPUT "How many boxes? ", NBOXES
200 FOR BOX=1 TO NBOXES
210 X1=RND*639: Y1=RND*199
220 X2=RND*639: Y2=RND*199
230 C=RND*15
240 GOSUB 900
250 NEXT BOX
260 BEEP
270 WHILE INKEY$="": WEND
280 SYSTEM
900 '----------
901 ' Fill Box from (x1,y1)-(x2,y2) in color C
910 FOR X=X1 TO X2
920 FOR Y=Y1 TO Y2
930 GOSUB 1000
940 NEXT Y
950 NEXT X
960 RETURN
1000 '----------
1001 '-- Put Pixel (color=C) at Location (X,Y)
1010 ROWBYTE = INT (X/8)
1020 BITMASK = 2 ^ (7 - (X MOD 8) )
1030 BYTEOFFSET = (Y * 80) + ROWBYTE
1040 ' Mask all but desired pixel position
1050 OUT &H3CE,8 '-- Graphics Bit Mask Register
1060 OUT &H3CF,BITMASK '-- Mask all but desired pixel
1070 ' Read previous contents to latches (all maps)
1080 OUT &H3C4,2 '-- Sequencer Map Mask
1090 OUT &H3C5,&HFF '-- Enable all 4 maps
1100 JUNK = PEEK (BYTEOFFSET)
1110 ' Blank the pixel
1120 POKE BYTEOFFSET,0
1130 ' Now set desired color in sequencer map mask
1140 OUT &H3C4,2 '-- Sequencer Map Mask
1150 OUT &H3C5,C '-- Desired Color
1160 ' Write 1's to selected planes
1170 POKE BYTEOFFSET,&HFF
1180 RETURN